package data;

import java.util.Date;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author Michal Hanzlik, Tomas Jiran
 */

/*
 create table Uzivatel (
 id_osoby             INT4                 not null,
 login                CHAR(32)             not null,
 heslo                CHAR(128)            not null,
 email                VARCHAR(256)         not null,
 datum_vytvoreni      DATE                 null,
 constraint PK_UZIVATEL primary key (id_osoby)
 );
 */
@Entity
@Table(name = "uzivatel")
@DiscriminatorValue("UZIVATEL")
public class Uzivatel extends Osoba {
    /**
     * login CHAR(32) not null,
     */
    @Column(nullable = false)
    private String login;

    /**
     * heslo CHAR(128) not null,
     */
    @Column(nullable = false)
    private String heslo;

    /**
     * email VARCHAR(256) not null,
     */
    @Column(nullable = false, columnDefinition = "varchar(256)")
    private String email;

    /**
     * created DATE null,
     */
    @Column(name = "datum_vytvoreni")
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date created;

    @OneToMany(mappedBy = "owner")
    private List<Film> filmy;

    @OneToMany(mappedBy = "owner")
    private List<Komentar> komentare;

    @OneToMany(mappedBy = "uzivatel")
    private List<Hodnoceni> hodnocene_film;

    public Uzivatel() {
    }

    public Uzivatel(String login, int ID_o) {
        super(ID_o);
        this.login = login;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getHeslo() {
        return heslo;
    }

    public void setHeslo(String heslo) {
        this.heslo = heslo;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public List<Film> getFilmy() {
        return filmy;
    }

    public void setFilmy(List<Film> filmy) {
        this.filmy = filmy;
    }

    public void setHodnocene_film(List<Hodnoceni> hodnocene_film) {
        this.hodnocene_film = hodnocene_film;
    }

    public List<Hodnoceni> getHodnocene_film() {
        return hodnocene_film;
    }
}